package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqMarket;
import com.drug.mingkang.Mapper.HqMarketMapper;
import com.drug.mingkang.service.HqMarketService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 总公司销售(HqMarket)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:42
 */
@Service("hqMarketService")
public class HqMarketServiceImpl implements HqMarketService {
    @Resource
    private HqMarketMapper hqMarketMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param marketId 主键
     * @return 实例对象
     */
    @Override
    public HqMarket queryById(String marketId) {
        return this.hqMarketMapper.queryById(marketId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqMarket> queryAllByLimit(int offset, int limit) {
        return this.hqMarketMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param hqMarket 实例对象
     * @return 实例对象
     */
    @Override
    public HqMarket insert(HqMarket hqMarket) {
        this.hqMarketMapper.insert(hqMarket);
        return hqMarket;
    }

    /**
     * 修改数据
     *
     * @param hqMarket 实例对象
     * @return 实例对象
     */
    @Override
    public HqMarket update(HqMarket hqMarket) {
        this.hqMarketMapper.update(hqMarket);
        return this.queryById(hqMarket.getMarketId());
    }

    /**
     * 通过主键删除数据
     *
     * @param marketId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String marketId) {
        return this.hqMarketMapper.deleteById(marketId) > 0;
    }
}